import { RPCClient } from '@alicloud/pop-core';

const getAlibabaToken = async () => {
  const client = new RPCClient({
    accessKeyId: "LTAI5tDFc4P7F6KWFpDNkt4Z",
    accessKeySecret: "dxXRFRDLYSSJhkaUL8AXegClBOSUoS",
    endpoint: 'http://nls-meta.cn-shanghai.aliyuncs.com',
    apiVersion: '2019-02-28'
  });

  try {
    const result = await client.request('CreateToken');
    console.log(result.Token);
    console.log("token = " + result.Token.Id);
    console.log("expireTime = " + result.Token.ExpireTime);
    return result.Token;
  } catch (error) {
    console.error('Error creating token:', error);
    throw error;
  }
};

export default getAlibabaToken;